﻿function ModelBussiness() { }
ModelBussiness.prototype.roomName = "";
ModelBussiness.prototype.init = function () {

    this.roomName = "ITC"
    this.bindHoverEvent();
    webapi.alarmCallBackHandler = modelBussiness.alarmManage;
    webapi.dataInit();
    console.log('init', webapi.dataInit);
}
//单击选中机柜
ModelBussiness.prototype.clickSelectCabinet = function (_obj, _face) {
    var _this = this;
    var color = 0xbfffea;
    console.log(_obj.name);
    if (_obj.name.indexOf("LightCubeBorder") > 0) {
        return;
    } else if (_obj.name.indexOf("rack_") >= 0
        && _obj.name.indexOf("_Server_") < 0
        && _obj.name.indexOf("_currentCabnet") < 0) {
        modelBussiness.mouseInCurrentObj = _obj;
        modelBussiness.commonFunc.addLightBoder(_obj, 0x00ffff, 1, null, {
            x: _obj.geometry.parameters.width + 20,
            y: _obj.geometry.parameters.height + 20,
            z: _obj.geometry.parameters.depth + 20,
        });
        modelBussiness.commonFunc.showMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 500, z: _obj.position.z }, function () {
            modelBussiness.commonFunc.removeLightBorder(modelBussiness.mouseInCurrentObj.name)
        });
    }
    else if (_obj.name.indexOf("_Server_") >= 0) {
        var _sobj = _obj;
        modelBussiness.commonFunc.removeLightBorder(modelBussiness.lastMouseInCurrentObj.name);
        modelBussiness.mouseInCurrentObj = _sobj;
        modelBussiness.commonFunc.showServerMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 1.5, z: _obj.position.z - 13 });
        if (modelBussiness.currentState == 10) {
            if (modelBussiness.currentShowServer.name == _sobj.name) {
                return;
            }
        }
        modelBussiness.commonFunc.addLightBoder(_sobj, 0x00ffff, 0.6, null, {
            x: _sobj.geometry.parameters.width + 4,
            y: _sobj.geometry.parameters.height + 4,
            z: _sobj.geometry.parameters.depth + 4,
        });
    }
    else if (_obj.name.indexOf("dev_T_") >= 0) {
        if (_obj.name.indexOf("OBJCREN") >= 0) {
            _obj = WT3DObj.commonFunc.findObject(_obj.name.split("OBJCREN")[0]);
        }
        modelBussiness.mouseInCurrentObj = _obj;
        WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x00ffff);

        modelBussiness.commonFunc.showDevEasyMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 100, z: _obj.position.z },
            function () {
                WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x000000);
            });
    }
}
ModelBussiness.prototype.currentShowCabinet = null;
ModelBussiness.prototype.currentState = 0;
//双击选中机柜
ModelBussiness.prototype.dbClickSelect = function (_obj, _face, formRoute) {


    var _this = this;
    if (modelBussiness.currentState > 20 && modelBussiness.currentState < 30) {
        return;
    }
    if (_obj.name.indexOf("dev_T_") >= 0) {
        if (_obj.name.indexOf("OBJCREN") >= 0) {
            _obj = WT3DObj.commonFunc.findObject(_obj.name.split("OBJCREN")[0]);
        }
        modelBussiness.mouseInCurrentObj = _obj;
        WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x00ffff);
        modelBussiness.commonFunc.showDevMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 100, z: _obj.position.z },
            function () {
                WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x000000);
                WT3DObj.commonFunc.changeCameraPosition(roomConfig.cameraPostion,
                    roomConfig.cameraTarget, 200, function () {
                    });
            });
    }
    else
        if (_obj.name.indexOf("_Server_") >= 0) {//双击服务器
            layer.closeAll();
            _this.dbClickSelectServer(_obj, _face);
            _this.commonFunc.removeLightBorder(_obj.name);
            this.currentState = 10;
        }
        else if (_obj.name.indexOf("rack_") >= 0 && _obj.name.indexOf("_currentCabnet") < 0) {
            layer.closeAll();
            if (this.currentState == 0 || this.currentState == 30) {
                layer.closeAll();
                $("#toolbar").fadeOut();
                $("#backBtn").fadeIn();
                this.currentState = 1;
                if (_obj.name.indexOf("_LightCubeBorder") >= 0) {
                    _obj = WT3DObj.commonFunc.findObject(_obj.name.replace("_LightCubeBorderLight", "").replace("_LightCubeBorder", ""));
                }
                _obj.visible = true;
                $.each(_obj.children, function (_cindex, _cobj) {
                    _cobj.visible = true;
                });
                this.currentShowCabinet = _obj;
                _this.commonFunc.removeLightBorder(_obj.name);
                this.hideAll("", function () {
                    _this.commonFunc.removeLightBorder(_obj.name);
                });
                //获取当前机柜的服务器列表
                this.createDevsByDevDatas(_obj);
                this.commonFunc.showCabnetDetail(_obj, function () {

                });
            }
        }
        else if (_obj.name.indexOf("rack_") >= 0 && _obj.name.indexOf("_currentCabnet") >= 0) {
            if (this.currentState == 1) {
                _this.openCabDoor(_obj);
            } else if (this.currentState == 10) {
                this.currentState = 1;
                this.backShowSingleServer();
            }
        }
        else if (_obj.name == "door_Left" || "door_Right" == _obj.name) {
            modelBussiness.DoorOpenOrClose();
            return true;
        }
}

//touchStart
ModelBussiness.prototype.foreSelectedObj = null;
ModelBussiness.prototype.currentTouchedObj = null;
ModelBussiness.prototype.touchStartTime = 0;
ModelBussiness.prototype.touchStart = function (_obj, face, row, col, book) {
    layer.closeAll();
    var _this = modelBussiness;

    WT3DObj.runRotationState = 0;
    WT3DObj.controls.autoRotate = false
    if (WT3DObj.runRotationStateIndex) {
        clearTimeout(WT3DObj.runRotationStateIndex);
    }
    WT3DObj.runRotationStateIndex = setTimeout(function () {
        WT3DObj.runRotationState = 1;
        layer.closeAll();
        WT3DObj.commonFunc.changeCameraPosition(roomConfig.cameraPosition
            , roomConfig.cameraTarget, 500,
            function () {
                WT3DObj.controls.autoRotate = true;

            });
    }, 1000 * 10);

    if (_obj.name.indexOf("OBJCREN") >= 0) {
        _obj = WT3DObj.commonFunc.findObject(_obj.name.split("OBJCREN")[0]);
    }


    _this.currentTouchedObj = _obj;
    _this.touchStartTime = new Date().getTime();
    _this.mouseOverInCallBack(_this.currentTouchedObj);

    //if (_this.foreSelectedObjTimeIndex) {
    //    clearTimeout(_this.foreSelectedObjTimeIndex)
    //}
    if (_this.foreSelectedObj && _this.foreSelectedObj.name == _obj.name) {//第二次点击
        _this.doubleClick(_obj);
        setTimeout(function () {
            _this.foreSelectedObj = null;
        }, 10);
    }
    if (_this.foreSelectedObj) {
        WT3DObj.commonFunc.setSkinColorByObj(_this.foreSelectedObj, 0x000000);
    }
    _this.foreSelectedObj = _obj;
    //_this.foreSelectedObjTimeIndex = setTimeout(function () {
    //    if (_this.foreSelectedObj) {
    //        WT3DObj.commonFunc.setSkinColorByObj(_this.foreSelectedObj, 0x000000);
    //    }
    //    _this.foreSelectedObj = null;
    //}, 1000);
}

//onTouchEnd
ModelBussiness.prototype.onTouchEnd = function (event) {
    var _this = modelBusiness;
    if (_this.currentTouchedObj) {
        console.log(_this.currentTouchedObj);
    }
    if (new Date().getTime() - modelBussiness.touchStartTime > 1000) {
        _this.singleClick(_this.currentTouchedObj);

    }
}
ModelBussiness.prototype.onTouchMove = function (event) {


    if (modelBussiness && modelBussiness.mouseEvent) {
        if (modelBussiness.touchMoveDis) {
            var movex = Math.abs(event.touches[0].clientX - modelBussiness.touchMoveDis.x);
            var movey = Math.abs(event.touches[0].clientY - modelBussiness.touchMoveDis.y);
            if (movex > 1 || movey > 1) {
                layer.closeAll();
                _this.currentTouchedObj = null;
                modelBussiness.touchStartTime = new Date().getTime();
            }
        }

        modelBussiness.touchMoveDis = {
            x: event.touches[0].clientX,
            y: event.touches[0].clientY
        }
    }


}


//双击大门
ModelBussiness.prototype.DoorState = "close";
ModelBussiness.prototype.DoorObjs = null;
ModelBussiness.prototype.DoorOpenOrClose = function () {
    if (!modelBussiness.DoorObjs) {
        modelBussiness.DoorObjs = WT3DObj.commonFunc.findObjectsByNames(["door_Left", "door_Right"]);
    }
    if (modelBussiness.DoorState == "running") {
        return;
    }
    if (modelBussiness.DoorState == "close") {
        modelBussiness.DoorState = "running";
        //打开门
        var rotate = { y: Math.PI / 2 };
        new TWEEN.Tween(rotate).to({ y: -Math.PI / 6 }, 2000)
            .onUpdate(function () {
                var _vthis = this;
                $.each(modelBussiness.DoorObjs, function (_index, _obj) {
                    if (_obj.name == "door_Left") {
                        _obj.rotation.y = _vthis.y;
                    } else {
                        _obj.rotation.y = Math.PI - _vthis.y;
                    }
                });
            }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                modelBussiness.DoorState = "open";
            }).start();
    } else {
        modelBussiness.DoorState = "running";
        //关闭门
        var rotate = { y: -Math.PI / 6 };
        new TWEEN.Tween(rotate).to({ y: Math.PI / 2 }, 2000)
            .onUpdate(function () {
                var _vthis = this;
                $.each(modelBussiness.DoorObjs, function (_index, _obj) {
                    if (_obj.name == "door_Left") {
                        _obj.rotation.y = _vthis.y;
                    } else {
                        _obj.rotation.y = Math.PI - _vthis.y;
                    }
                });
            }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                modelBussiness.DoorState = "close";
            }).start();
    }
}
//双击显示服务器
ModelBussiness.prototype.currentShowServer = [];
ModelBussiness.prototype.showSingleServerNeedVitures = [];
ModelBussiness.prototype.dbClickSelectServer = function (_obj, _face) {
    //隐藏虚化其他服务器
    var _this = modelBussiness;
    var cabname = _obj.name.split("_Server_")[0];
    var needVitureDevs = [];
    $.each(_this.Devs[cabname], function (_dindex, _dobj) {
        if (_dobj.name != _obj.name && _obj.name.indexOf(_dobj.name + "_") < 0) {
            needVitureDevs.push(_dobj);
        } else {
            WT3DObj.commonFunc.changeObjsOpacity([_dobj], 0.2, 1, 1000, function () {
            });
            _this.currentShowServer = _dobj;
        }
    });
    needVitureDevs.push(_this.currentShowCabinet);
    console.log(needVitureDevs);
    WT3DObj.commonFunc.changeObjsOpacity(needVitureDevs, 1, 0.2, 1000, function () {
    });
    _this.showSingleServerNeedVitures = needVitureDevs;
}
ModelBussiness.prototype.backShowSingleServer = function () {
    if (modelBussiness.showSingleServerNeedVitures.length > 0) {
        WT3DObj.commonFunc.changeObjsOpacity(modelBussiness.showSingleServerNeedVitures, 0.2, 1, 1000, function () {
            modelBussiness.showSingleServerNeedVitures = [];
        });
    }
}
//加载端口
ModelBussiness.prototype.loadPorts = function () {
    //模拟数据


}

ModelBussiness.prototype.currentOpenDoorCabinet = null;
//双击机柜开门
ModelBussiness.prototype.openCabDoor = function (_obj, type) {
    //7 8     9
    if (_obj.doors) {
    } else {
        _obj.doors = {
            leftDoor: _obj.children[7],
            rightDoor: _obj.children[8],
            mainDoor: _obj.children[9],
        }
    }
    modelBussiness.currentOpenDoorCabinet = _obj;
    console.log(_obj.doors);
    if (_obj && _obj.doors) {
        if (modelBussiness.lastMouseInCurrentObj.name.indexOf("OBJCREN7") > 0
            || modelBussiness.lastMouseInCurrentObj.name.indexOf("OBJCREN8") > 0 || type == "twodoor" || type == "all") {
            this.commonFunc.opcabinetBackLeftdoor(_obj.doors.leftDoor);
            this.commonFunc.opcabinetBackRightdoor(_obj.doors.rightDoor);
        }

        if (modelBussiness.lastMouseInCurrentObj.name.indexOf("OBJCREN9") > 0 || type == "onedoor" || type == "all") {
            this.commonFunc.opcabinetMaindoor(_obj.doors.mainDoor);
        }

        setTimeout(function () {

            if (_obj.doors.leftDoor.doorState == undefined || _obj.doors.leftDoor.doorState == "close") {

                if (_obj.doors.rightDoor.doorState == undefined || _obj.doors.rightDoor.doorState == "close") {

                    if (_obj.doors.mainDoor.doorState == undefined || _obj.doors.mainDoor.doorState == "close") {
                        modelBussiness.commonFunc.showCabnetDetail(_obj, function () {
                        });
                    }
                }
            }
        }, 200);
    }
}
//关闭机柜
ModelBussiness.prototype.closeCabDoor = function (backBtn) {
    //7 8     9
    if (this.currentOpenDoorCabinet && this.currentOpenDoorCabinet.doors) {
        var _obj = this.currentOpenDoorCabinet;
        if (modelBussiness.lastMouseInCurrentObj.name.indexOf("OBJCREN7") > 0 || modelBussiness.lastMouseInCurrentObj.name.indexOf("OBJCREN8") > 0) {
            this.commonFunc.opcabinetBackLeftdoor(_obj.doors.leftDoor, "close");
            this.commonFunc.opcabinetBackRightdoor(_obj.doors.rightDoor, "close");
        } else if (modelBussiness.lastMouseInCurrentObj.name.indexOf("OBJCREN9") > 0) {
            this.commonFunc.opcabinetMaindoor(_obj.doors.mainDoor, "close");
        } else if (backBtn) {
            this.commonFunc.opcabinetBackLeftdoor(_obj.doors.leftDoor, "close");
            this.commonFunc.opcabinetBackRightdoor(_obj.doors.rightDoor, "close");
            this.commonFunc.opcabinetMaindoor(_obj.doors.mainDoor, "close");
        }
    }
}

//服务器
ModelBussiness.prototype.serverDetail = function () {

}
ModelBussiness.prototype.Devs = [];
ModelBussiness.prototype.currentShowServerNames = [];
//根据设备数据 生成设备
ModelBussiness.prototype.createDevsByDevDatas = function (cabinetobj) {
    var _this = modelBussiness;
    _this.currentShowServerNames = [];
    var cabinetName = cabinetobj.name;
    if (_this.Devs[cabinetName] && _this.Devs[cabinetName].length > 0) {
        $.each(_this.Devs[cabinetName], function (_index, _obj) {
            _obj.visible = true;
            _this.currentShowServerNames.push(_obj.name);
        });
        setTimeout(function () {

            var currentCanNet = WT3DObj.commonFunc.findObject(cabinetobj.name + "_currentCabnet");
            WT3DObj.commonFunc.changeCameraPosition({ x: currentCanNet.position.x - 500, y: currentCanNet.position.y + 300, z: currentCanNet.position.z },
                { x: currentCanNet.position.x, y: currentCanNet.position.y, z: currentCanNet.position.z }, 1000, function () {
                });

        }, 1000);

    } else {
        var devJsonModels = [];
        //1u 高度8.5 位置42
        var info = webapi.CabInfosCache.Modelobjs["m_" + cabinetName];
        var devs = [];
        var umax = 42;
        var uUsed = [];
        if (info) {
            if (info.children) {
                $.each(info.children, function (_ci, _co) {
                    if (parseInt(_co.uStart) > info.uMax) {
                        console.log("数据有误：超出u位限制");
                        console.log(_co);
                        layer.msg("data Error:{out of uMax}");
                    } else {
                        for (var i = parseInt(_co.uStart); i <= parseInt(_co.uEnd); i++) {
                            uUsed[i] = 1;
                        }
                        var addobj = {
                            id: _co.id,
                            type: "used",
                            devURange: {
                                max: parseInt(_co.uEnd),
                                min: parseInt(_co.uStart)
                            },
                        };
                        if (_co.img) {
                            addobj.imgs = {
                                up: "../img/3dImg/rack_inside.jpg",
                                down: "../img/3dImg/rack_inside.jpg",
                                fore: "../img/3dImg/rack_inside.jpg",
                                behind: "../img/3dImg/rack_inside.jpg",
                                left: _co.img,
                                right: _co.img,
                            }
                        }
                        devs.push(addobj);
                    }
                });
            }
            umax = info.uMax;
        }
        for (var i = 1; i <= umax; i++) {
            if (!uUsed[i]) {
                devs.push({
                    id: "s_noused_" + i,
                    type: "empty",
                    devURange: {
                        max: i,
                        min: i
                    },
                });
            }
        }
        console.log(devs);
        if (devs && devs.length > 0) {
            $.each(devs, function (_index, _obj) {
                var height = (_obj.devURange.max - _obj.devURange.min + 1) * (345 / umax);
                var positiony = (_obj.devURange.min - 1) * (360 / umax - 0.2) + cabinetobj.position.y - 175 + height / 2;

                var postioinx = cabinetobj.position.x;
                var postioinz = cabinetobj.position.z;
                var rotationy = cabinetobj.rotation.y + Math.PI;
                var name = cabinetobj.name + "_Server_" + _obj.id;
                var width = 118;
                if (!_obj.imgs) {
                    var servvers = ["../img/3dImg/server2.jpg", "../img/3dImg/server3.jpg", "../img/3dImg/server1.jpg"];
                    _obj.imgs = {
                        up: "../img/3dImg/rack_inside.jpg",
                        down: "../img/3dImg/rack_inside.jpg",
                        fore: servvers[parseInt(Math.random() * 3)],
                        behind: servvers[parseInt(Math.random() * 3)],
                        left: servvers[parseInt(Math.random() * 3)],
                        right: servvers[parseInt(Math.random() * 3)],
                    }
                }
                if (_obj.type == "empty") {
                    width = 100;
                    _obj.imgs = {
                        up: "",
                        down: "",
                        fore: "",
                        behind: "",
                        left: "",
                        right: "",
                    }
                }
                var server = getSingleServerModel(name, { "x": postioinx, "y": positiony, "z": postioinz }, height, rotationy, _obj.id, _obj.imgs, width);
                devJsonModels.push(server);
                _this.currentShowServerNames.push(name);
            });
        }
        var currentCabnet = getCabinetModel(cabinetobj.name + "_currentCabnet",
            { x: 1, y: 1, z: 1 },
            { "x": cabinetobj.position.x, "y": cabinetobj.position.y, "z": cabinetobj.position.z },
            [{ "direction": "y", "degree": 0 }],
            2, umax);
        devJsonModels.push(currentCabnet);
        _this.currentShowServerNames.push(cabinetobj.name + "_currentCabnet");

        WT3DObj.commonFunc.loadModelsByJsons(devJsonModels, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true, function () {
            _this.Devs[cabinetName] = WT3DObj.commonFunc.findObjectsByNames(_this.currentShowServerNames);

            setTimeout(function () {

                var currentCanNet = WT3DObj.commonFunc.findObject(cabinetobj.name + "_currentCabnet");
                WT3DObj.commonFunc.changeCameraPosition({ x: currentCanNet.position.x - 500, y: currentCanNet.position.y + 300, z: currentCanNet.position.z },
                    { x: currentCanNet.position.x, y: currentCanNet.position.y, z: currentCanNet.position.z }, 1000, function () {
                    });

            }, 1000);

        });
    }

}
//=======================================================温度=======================================================
ModelBussiness.prototype.temptureSpaceState = 0;
//温度显示
ModelBussiness.prototype.showTemptureMap = function (callBack) {
    console.log(this.temptureSpaceState);

    var _this = this;
    if (_this.temptureSpaceState == 0) {
        $("#backBtn").fadeIn();
  
        layer.closeAll();
        $("#toolbar").fadeOut();
        _this.temptureSpaceState = 1;
        _this.createHeatMapModels("temptureObj", callBack);

    } else {
        _this.temptureSpaceState = 0;
        _this.hideAllTemptureMapObjs();
    }

}
ModelBussiness.prototype.hideAllTemptureMapObjs = function () {
    WT3DObj.destoryObj("temptureObj");
    for (var i = 0; i < 20; i++) {
        WT3DObj.destoryObj("temptureObj_" + i);
    }
}
//创建热力图
ModelBussiness.prototype.createHeatMapModels = function (name, callBack) {
    console.log('name', name);
    var _this = this;
    var scaleRate = 1;
    if (roomConfig.buildData.baseConfig && roomConfig.buildData.baseConfig.normRackSize) {
        scaleRate = roomConfig.buildData.baseConfig.normRackSize.width / 350;
    }
    _this.getHeatMapDataValue(function (_data) {
     
        console.log('ModelBussiness 535', _data);
        var modeljson = {
            show: true,
            name: name,
            showSortNub: 50000,
            id: "",
            objType: "CloudChart",
            size: { x: 500, y: 500, z: 0 },
            position: {
                x: roomConfig.centerx / scaleRate,
                y: roomConfig.minheight / scaleRate,
                z: roomConfig.centerz / scaleRate,
            },
            scale: {
                x: (roomConfig.length / 500) / scaleRate,
                y: (roomConfig.width / 500) / scaleRate,
                z: 0
            },
            rotation: { x: -Math.PI / 2, y: 0, z: 0 },
            pictype: "rectangle", //arc圆 rectangle矩形 triangle三角形
            side: 1,
            opacity: 0.3,
            maxValue: 45,
            minValue: 0,
            materialType: "basic",
            panelColor: 0x00ffff,
            background: {
                color: 0xffffff,
                size: {
                    x: 100, y: 100,//画布大小
                    r: 50,//圆半径
                    start: 0,
                    end: 360,
                    angle_r: 10, x1: 0, y1: 0, x2: 100, y2: 100, x3: 100, y3: 0
                },
                imgurl: "",
                type: "arc", //arc圆 rectangle矩形 triangle三角形
                border: {
                    color: 0xff0000,
                    width: 1
                }
            },
            values: _data.data,
            // values: [{ x: 120, y: 120, value: 9 }],


        };
        console.log("*************************")
        console.log(WT3DObj)
        console.log(WT3DObj.InitAddObject)
        console.log("*************************")
        WT3DObj.InitAddObject(modeljson);

 

        // 循环创建热力图  创建十层
        for (var i = 0; i < 10; i++) {
            modeljson.position.y += (roomConfig.maxheight / 10) / scaleRate;

            modeljson.name = name + "_" + i;
            modeljson.values = _data.data;
            // modeljson.values = [{ x: 120, y: 120, value: 9 }]




            WT3DObj.InitAddObject(modeljson);
        }
    }, callBack);
};
ModelBussiness.prototype.getHeatMapDataValue = function (suc, callBack) {
    console.log(suc);
    webapi.getTemptureValue(function (result) {

        var heatMapData = {};

        $.each(result, function (_reindex, _reobj) {
            heatMapData["d_" + _reobj.id] = _reobj;
        });

        var scaleRate = 1;
        if (roomConfig.buildData.baseConfig && roomConfig.buildData.baseConfig.normRackSize) {
            scaleRate = roomConfig.buildData.baseConfig.normRackSize.width / 350;
        }
        var datas = [];
        var maxvalue = 0;
        //模拟数据
        for (i = 20; i < 500; i += 50) {
            for (j = 20; j < 500; j += 50) {
                var value = Math.floor(Math.random() * 10) + 1;
                if (value > maxvalue) {
                    maxvalue = value;
                }
                datas.push({
                    x: i,
                    y: j,
                    value: value
                });
            }
        }
        var mnames = [];
        var mtemp = [];
        var racks = getRacksConfig();
        var devs = getDevsConfig();
        devs = devs.concat(racks);
        $.each(devs, function (_index, _obj) {
            var x = (_obj.position.x - roomConfig.centerx + roomConfig.length / 2) / roomConfig.length * 500;
            var z = (_obj.position.z - roomConfig.centerz + roomConfig.width / 2) / roomConfig.width * 500;
            var tvalue = 0;
            if (heatMapData["d_" + _obj.dataId]) {
                tvalue = heatMapData["d_" + _obj.dataId].temptureValue;
            }
            datas.push({
                x: x * scaleRate,
                y: z * scaleRate,
                value: tvalue
            });
        });
        var rdata = {
            max: 100,
            data: datas
        };

        if (suc) {
            suc(rdata);
        }
        if (callBack) {
            callBack(mtemp);
        }
    });
}




//=======================================================湿度=======================================================
ModelBussiness.prototype.doShowHumidityTmpObjs = [];
ModelBussiness.prototype.doShowHumidityState = 0;//0表示关闭
ModelBussiness.prototype.showHumidity = function () {
    var _this = this;
    if (_this.doShowHumidityState == 0) {
        _this.doShowHumidityState = -1;
    } else if (_this.doShowHumidityState == 1) {
        _this.backBtn();
        return;
    } else {
        return;
    }
    _this.doShowHumidityTmpObjs = [];
    var needtime = 0;
    setTimeout(function () {
        _this.hideAllCabinet("aa", function () {
            var HumDevs = [];
            $.each(getDevsConfig(), function (_i, _o) {
                if (_o.type == "wdcgq") {
                    HumDevs.push(_o);
                }
            })
            webapi.getHumValue(function (result) {
                var humData = {};

                $.each(result, function (_reindex, _reobj) {
                    humData["d_" + _reobj.id] = _reobj;
                });
                $.each(HumDevs, function (_hi, _ho) {
                    //显示温度
                    var postition = { x: _ho.position.x, y: _ho.position.y + 300, z: _ho.position.z };
                    var humValue = 0;
                    if (humData["d_" + _ho.dataId]) {
                        humValue = humData["d_" + _ho.dataId].humValue;
                    }
                    //显示
                    var tmpjosn = {
                        show: true,
                        name: "humidity" + _hi,
                        objType: "Humidity",
                        position: postition,
                        rotation: [{ "direction": "x", "degree": 0 }],
                        scale: { "x": 2, "y": 2, "z": 2 },
                        value: humValue,
                    }
                    var temptureobj = WT3DObj.InitAddObject(tmpjosn);
                    _this.doShowHumidityTmpObjs.push("humidity" + _hi);
                    //获取
                    var tmpValue = 40 + Math.random() * 10;
                    tmpValue = parseFloat((tmpValue + "").substr(0, 4));
                    if (temptureobj) {
                        temptureobj.renderOrder = 1000;
                        temptureobj.children[3].renderOrder = 1000;
                        temptureobj.changeThermoneter(tmpValue);
                    }
                });
                WT3DObj.commonFunc.changeCameraPosition({ x: -4566.719345914818, y: 3553.666501925617, z: -4550.526946651548 }, { x: -1427.7679063207208, y: 244.3943174839315, z: -590.5426881625292 }, 1000, function () { });
                _this.doShowHumidityState = 1;
            });
        });
    }, needtime);
}
ModelBussiness.prototype.closeHumidity = function () {
    var _this = this;
    if (_this.doShowHumidityState == 1) {
        _this.doShowHumidityState = -1;
        //删除临时对象
        if (_this.doShowHumidityTmpObjs && _this.doShowHumidityTmpObjs.length && _this.doShowHumidityTmpObjs.length > 0) {
            $.each(_this.doShowHumidityTmpObjs, function (_index, _obj) {
                WT3DObj.destoryObj(_obj);
            });
        }
        if (_this.needHideCabinets.length > 0) {
            WT3DObj.commonFunc.changeCameraPosition({ x: 2531, y: 3967, z: -1150 }, { x: -615, y: 0, z: -35 }, 1000, function () {
                $.each(_this.needHideCabinets, function (_index, _obj) {
                    _obj.visible = true;
                });
            });
        }
        _this.doShowHumidityTmpObjs = [];
        _this.doShowHumidityState = 0;
    }
}
ModelBussiness.prototype.hideDevs = function () {
    var _this = this;
    if (this.currentShowServerNames.length > 0) {
        var devs = [];
        var cabinetName = "";
        $.each(_this.currentShowServerNames, function (_index, _obj) {
            var sobj = WT3DObj.commonFunc.findObject(_obj);
            if (sobj) {
                sobj.visible = false;
                devs.push(sobj);
                cabinetName = sobj.name.split("_Server_")[0];
            }
        });
        //if (_this.Devs[cabinetName] == undefined) {
        //    _this.Devs[cabinetName] = {
        //        devs: devs
        //    };
        //} else {
        //    _this.Devs[cabinetName].devs = devs;
        //}
    }
    _this.currentShowServerNames = [];
}
//=======================================================利用率=======================================================
ModelBussiness.prototype.rateSpaceState = 0;
ModelBussiness.prototype.rateSpaceCubes = [];
ModelBussiness.prototype.rateSpaceCubeNames = [];
ModelBussiness.prototype.showSpaceRate = function () {
    var _this = this;
    if (_this.rateSpaceState == 0) {
        _this.rateSpaceState = 1;
        $("#backBtn").fadeIn();
        layer.closeAll();
        $("#toolbar").fadeOut();
        //隐藏所有机柜
        _this.hideAllCabinet("", function () {
            webapi.getRacksUsedRateValue(function (result) {
                var rackRate = {};
                $.each(result, function (_reindex, _reobj) {
                    rackRate["d_" + _reobj.id] = _reobj;
                });
                var racks = getRacksConfig();
                if (_this.rateSpaceCubeNames.length <= 0) {
                    $.each(racks, function (_rindex, _robj) {
                        var _name = _robj.name;
                        var rateValue = 0;
                        if (rackRate["d_" + _robj.dataId]) {
                            rateValue = rackRate["d_" + _robj.dataId].useRate;
                        }
                        var itcobj = WT3DObj.commonFunc.findObject(_name);
                        if (itcobj) {
                            _this.commonFunc.createRateCube(_name,
                                { x: 560, y: 900, z: 320 },
                                { x: itcobj.position.x, y: itcobj.position.y, z: itcobj.position.z },
                                { x: 0, y: itcobj.rotation.y, z: 0 },
                                rateValue, { timelong: 1000 });
                        }
                    });
                }
                else {
                    $.each(racks, function (_rindex, _robj) {
                        var _name = _robj.name;
                        var rateValue = 0;
                        if (rackRate["d_" + _robj.dataId]) {
                            rateValue = rackRate["d_" + _robj.dataId].useRate;
                        }
                        var itcobj = WT3DObj.commonFunc.findObject(_name);
                        if (itcobj) {
                            _this.commonFunc.createRateCube(_name,
                                { x: 560, y: 900, z: 320 },
                                { x: itcobj.position.x, y: itcobj.position.y, z: itcobj.position.z },
                                { x: 0, y: itcobj.rotation.y, z: 0 },
                                rateValue, { timelong: 1000 });
                        }

                    });
                }
            });
        });
    }
    else {
        _this.hideSpaceRate();
        if (_this.needHideCabinets.length > 0) {
            WT3DObj.commonFunc.changeCameraPosition({ x: 2531, y: 3967, z: -1150 }, { x: -615, y: 0, z: -35 }, 1000, function () {
                $.each(_this.needHideCabinets, function (_index, _obj) {
                    if (_obj.name.indexOf("_rate_") < 0 && _obj.name.indexOf("_energy_") < 0 && _obj.name.indexOf("_yearCube_") < 0) {
                        _obj.visible = true;
                    }
                });
            });
        }
    }
}
ModelBussiness.prototype.hideSpaceRate = function () {
    modelBussiness.rateSpaceState = 0;
    if (modelBussiness.rateSpaceCubes && modelBussiness.rateSpaceCubes.length > 0) {
        $.each(modelBussiness.rateSpaceCubes, function (_index, _obj) {
            _obj.visible = false;
            if (!_obj.oldPositionY) {
                _obj.oldPositionY = _obj.position.y;
            }
            _obj.position.y += 1000000;
        });
    }
}

//=======================================================功率=======================================================
ModelBussiness.prototype.energySpaceState = 0;
ModelBussiness.prototype.energySpaceCubes = [];
ModelBussiness.prototype.energySpaceCubeNames = [];
ModelBussiness.prototype.showEnergyRate = function () {
    var _this = this;
    if (_this.energySpaceState == 0) {
        _this.energySpaceState = 1;
        $("#backBtn").fadeIn();
        layer.closeAll();
        $("#toolbar").fadeOut();
        //隐藏所有机柜
        _this.hideAllCabinet("", function () {
            webapi.getHumValue(function (result) {
                
                var rackRate = {};
                $.each(result, function (_reindex, _reobj) {
                    rackRate["d_" + _reobj.cabid] = _reobj;
                });
                var racks = getRacksConfig();
                if (_this.energySpaceCubeNames.length <= 0) {
                    $.each(racks, function (_rindex, _robj) {
                        var _name = _robj.name;
                        var rateValue = 0;
                        if (rackRate["d_" + _robj.dataId]) {
                            rateValue = rackRate["d_" + _robj.dataId].euRate;
                        }
                        var itcobj = WT3DObj.commonFunc.findObject(_name);
                        if (itcobj) {
                            _this.commonFunc.createEnergyCube(_name,
                                { x: 560, y: 900, z: 320 },
                                { x: itcobj.position.x, y: itcobj.position.y, z: itcobj.position.z },
                                { x: 0, y: itcobj.rotation.y, z: 0 },
                                rateValue, { timelong: 1000 });
                        }
                    });
                }
                else {
                    $.each(racks, function (_rindex, _robj) {
                        var _name = _robj.name;
                        var rateValue = 0;
                        if (rackRate["d_" + _robj.dataId]) {
                            rateValue = rackRate["d_" + _robj.dataId].euRate;
                        }
                        var itcobj = WT3DObj.commonFunc.findObject(_name);
                        if (itcobj) {
                            _this.commonFunc.createEnergyCube(_name,
                                { x: 560, y: 900, z: 320 },
                                { x: itcobj.position.x, y: itcobj.position.y, z: itcobj.position.z },
                                { x: 0, y: itcobj.rotation.y, z: 0 },
                                rateValue, { timelong: 1000 });
                        }

                    });
                }
            });
        });
    }
    else {
        _this.hideEnergyRate();
        if (_this.needHideCabinets.length > 0) {
            WT3DObj.commonFunc.changeCameraPosition({ x: 2531, y: 3967, z: -1150 }, { x: -615, y: 0, z: -35 }, 1000, function () {
                $.each(_this.needHideCabinets, function (_index, _obj) {
                    if (_obj.name.indexOf("_rate_") < 0 && _obj.name.indexOf("_energy_") < 0 && _obj.name.indexOf("_yearCube_") < 0) {
                        _obj.visible = true;
                    }
                });
            });
        }
    }
}
ModelBussiness.prototype.hideEnergyRate = function () {
    modelBussiness.energySpaceState = 0;
    if (modelBussiness.energySpaceCubes && modelBussiness.energySpaceCubes.length > 0) {
        $.each(modelBussiness.energySpaceCubes, function (_index, _obj) {
            _obj.visible = false;
            if (!_obj.oldPositionY) {
                _obj.oldPositionY = _obj.position.y;
            }
            _obj.position.y += 1000000;
        });
    }
}

//=======================================================U位=======================================================
ModelBussiness.prototype.agesSpaceState = 0;
ModelBussiness.prototype.agesSpaceCubes = [];
ModelBussiness.prototype.agesSpaceCubeNames = [];
ModelBussiness.prototype.showUsageMap = function () {
    var _this = this;
    var cabs = getRacksConfig();

    if (_this.agesSpaceState == 0) {
        _this.agesSpaceState = 1;
        $("#backBtn").fadeIn();
        layer.closeAll();
        $("#toolbar").fadeOut();
        //隐藏所有
        _this.hideAllCabinet("aaaa", function () {
            webapi.getUDetailInfos(null, function () {
                if (_this.agesSpaceCubeNames.length <= 0) {
                    console.log('modelBusiness.js 956',cabs, webapi.CabInfosCache);
                    for (var i = 0; i < cabs.length; i++) {
                        var servers = webapi.CabInfosCache.Dataobjs["d_" + cabs[i].dataId]?.children;
                        var rateValue = Math.random();
                        var ageValue = [];
                        if (servers && servers.length > 0) {
                            $.each(servers, function (_si, _sobj) {
                                ageValue.push({
                                    value: _sobj.lastTemperature,
                                    max: _sobj.uEnd,
                                    min: _sobj.uStart
                                });
                            })
                        }
                        var style = {
                            borderColor: 0x444444,
                            outColor: 0xffffff,
                            outOprity: 0.1
                        };
                        var itcobj = WT3DObj.commonFunc.findObject(cabs[i].name);
                        if (itcobj) {
                            _this.commonFunc.createUseageCube(cabs[i].name,
                                { x: 560, y: 900, z: 320 },
                                { x: cabs[i].position.x, y: cabs[i].position.y, z: cabs[i].position.z },
                                { x: 0, y: itcobj.rotation.y, z: 0 },
                                ageValue,
                                style, { timelong: 1000 }, i);
                        }
                    }

                }
                else {
                    for (var i = 0; i < cabs.length; i++) {
                        var ageValue = [];
                        var style = {
                            borderColor: 0xffffff,
                            outColor: 0xffffff,
                            outOprity: 0.1
                        };
                        var itcobj = WT3DObj.commonFunc.findObject(cabs[i].name);
                        if (itcobj) {
                            _this.commonFunc.createUseageCube(cabs[i].name,
                                { x: 560, y: 900, z: 320 },
                                { x: cabs[i].position.x, y: cabs[i].position.y, z: cabs[i].position.z },
                                { x: 0, y: itcobj.rotation.y, z: 0 },
                                ageValue,
                                style, { timelong: 1000 }, i);
                        }
                    }
                }

            });

        });
    } else {
        this.hideUsageSpaceRate();
        if (_this.needHideCabinets.length > 0) {
            WT3DObj.commonFunc.changeCameraPosition({ x: 2531, y: 3967, z: -1150 }, { x: -615, y: 0, z: -35 }, 1000, function () {
                $.each(_this.needHideCabinets, function (_index, _obj) {
                    if (_obj.name.indexOf("_rate_") < 0 && _obj.name.indexOf("_energy_") < 0 && _obj.name.indexOf("_yearCube_") < 0) {
                        _obj.visible = true;
                    }
                });
            });
        }
    }
}
ModelBussiness.prototype.hideUsageSpaceRate = function () {
    modelBussiness.agesSpaceState = 0;
    if (modelBussiness.agesSpaceCubes && modelBussiness.agesSpaceCubes.length > 0) {
        $.each(modelBussiness.agesSpaceCubes, function (_index, _obj) {
            _obj.visible = false;
        });
    }
}


//=======================================================承重=======================================================
ModelBussiness.prototype.BearingState = 0;
ModelBussiness.prototype.BearingCubes = [];
ModelBussiness.prototype.BearingCubeNames = [];
ModelBussiness.prototype.showBearing = function () {
    var _this = this;
    var cabs = getRacksConfig();

    if (_this.BearingState == 0) {
        _this.BearingState = 1;
        $("#backBtn").fadeIn();
        layer.closeAll();
        $("#toolbar").fadeOut();
        //隐藏所有
        _this.hideAllCabinet("aaaa", function () {
  
            webapi.getRacksBearingValue(function (result) {

                console.log(_this.BearingState);
                var bearingRate = {};
                $.each(result, function (_reindex, _reobj) {
                    bearingRate["d_" + _reobj.cabid] = _reobj;
                });

                var style = {
                    borderColor: 0xffffff,
                    innerColor: 0x6495ed,
                    innerOprity: 1,
                    outColor: 0xffffff,
                    outOprity: 0.1
                };
                if (_this.BearingCubeNames.length <= 0) {
                    for (var i = 0; i < cabs.length; i++) {
                        var bearingValue = 0;
                        if (bearingRate["d_" + cabs[i].dataId]) {
                            bearingValue = bearingRate["d_" + cabs[i].dataId].bearingRate;
                        }

                        if (bearingValue > 0.90) {
                            style.innerColor = 0xff0000;
                        } else if (bearingValue > 0.70) {
                            style.innerColor = 0xffa500;
                        } else if (bearingValue > 0.50) {
                            style.innerColor = 0xffff00;
                        } else {
                            style.innerColor = 0x6495ed;

                        }
                        if (cabs[i]) {
                            var itcobj = WT3DObj.commonFunc.findObject(cabs[i].name);
                            if (itcobj) {

                                _this.commonFunc.createBearing(cabs[i].name,
                                    { x: 560, y: 900, z: 320 },
                                    { x: cabs[i].position.x, y: cabs[i].position.y, z: cabs[i].position.z },
                                    { x: 0, y: itcobj.rotation.y, z: 0 },
                                    bearingValue,
                                    style, { timelong: 1000 });

                            }
                        }
                    }
                }
                else {
                    for (var i = 0; i <= cabs.length; i++) {
                        var bearingValue = 0;
                        if (bearingRate["d_" + cabs[i].dataId]) {
                            bearingValue = bearingRate["d_" + cabs[i].dataId].bearingRate;
                        }
                        if (bearingValue > 0.90) {
                            style.innerColor = 0xff0000;
                        } else if (bearingValue > 0.70) {
                            style.innerColor = 0xffa500;
                        } else if (bearingValue > 0.50) {
                            style.innerColor = 0xffff00;
                        } else {
                            style.innerColor = 0x6495ed;

                        }
                        if (cabs[i]) {
                            var itcobj = WT3DObj.commonFunc.findObject(cabs[i].name);
                            if (itcobj) {

                                _this.commonFunc.createBearing(cabs[i].name,
                                    { x: 560, y: 900, z: 320 },
                                    { x: cabs[i].position.x, y: cabs[i].position.y, z: cabs[i].position.z },
                                    { x: 0, y: itcobj.rotation.y, z: 0 },
                                    bearingValue,
                                    style, { timelong: 1000 });
                            }
                        }
                    }
                }

            });

        });
    }
    else {
        _this.hideBearing();
        if (_this.needHideCabinets.length > 0) {
            WT3DObj.commonFunc.changeCameraPosition({ x: 2531, y: 3967, z: -1150 }, { x: -615, y: 0, z: -35 }, 1000, function () {
                $.each(_this.needHideCabinets, function (_index, _obj) {
                    if (_obj.name.indexOf("_bearing_") < 0 && _obj.name.indexOf("_yearCube_") < 0) {
                        _obj.visible = true;
                    }
                });
            });
        }
    }
}
ModelBussiness.prototype.hideBearing = function () {
    modelBussiness.BearingState = 0;
    if (modelBussiness.BearingCubes && modelBussiness.BearingCubes.length > 0) {
        $.each(modelBussiness.BearingCubes, function (_index, _obj) {
            if (!_obj.oldPositionY) {
                _obj.oldPositionY = _obj.position.y;
            }
            _obj.position.y = 100000;
            _obj.visible = false;
        });
    }
}


//=======================================================告警管理=======================================================
ModelBussiness.prototype.flashAlarm = true;
ModelBussiness.prototype.alarmManage = function () {
    /*
        主要定义了机柜、机柜内设备、其它动环设备这三种类型
    用 1 2 3 分别代表这三种类型
    */
    modelBussiness.nowAlarmsList = [];
    modelBussiness.nowAlarmsModelIdListIndex = [];
    var serverAlarm = [];
    $.each(webapi.alarmCache,
        function (_cindex, _obj) {
            var ale = "L4";
            if (_obj.alarmLevel == 1) {
                ale = "L1";
            } else if (_obj.alarmLevel == 2) {
                ale = "L2";
            } else if (_obj.alarmLevel == 3) {
                ale = "L3";
            }
            if (_obj && (_obj.devType == 1 || _obj.devType == 3)) {
                var info = getRelationInfoByDataId(_obj.devId);
                if (info) {
                    var aindex = modelBussiness.nowAlarmsModelIdListIndex.indexOf(info.modelId);
                    if (aindex < 0) {
                        modelBussiness.nowAlarmsList.push({
                            EquipName: info.modelId,
                            Alarms: [_obj],
                            AlarmLevelNub: _obj.alarmLevel,
                            children: [],
                            alarmFrom: "self",
                            AlarmLevel: ale,
                        });
                        modelBussiness.nowAlarmsModelIdListIndex.push(info.modelId);
                    } else {
                        modelBussiness.nowAlarmsList[aindex].Alarms.push(_obj);
                        if (modelBussiness.nowAlarmsList[aindex].AlarmLevelNub > _obj.alarmLevel) {
                            modelBussiness.nowAlarmsList[aindex].AlarmLevelNub = _obj.alarmLevel;
                            modelBussiness.nowAlarmsList[aindex].AlarmLevel = ale;
                        }
                    }

                }

            } else if (_obj && _obj.devType == 2) {//机柜内设备
                var server = webapi.ServerDevsCache["s_" + _obj.devId];
                if (server) {
                    var info = getRelationInfoByDataId(server.cabId);//机柜信息
                    if (info) {
                        var aindex = modelBussiness.nowAlarmsModelIdListIndex.indexOf(info.modelId);
                        if (aindex < 0) {
                            modelBussiness.nowAlarmsList.push({
                                alarmFrom: "children",
                                EquipName: info.modelId,
                                Alarms: [_obj],
                                AlarmLevelNub: _obj.alarmLevel,
                                children: [],
                                AlarmLevel: ale,
                            });
                            modelBussiness.nowAlarmsModelIdListIndex.push(info.modelId);
                            aindex = modelBussiness.nowAlarmsModelIdListIndex.length - 1;
                        } else {
                            modelBussiness.nowAlarmsList[aindex].Alarms.push(_obj);
                            if (modelBussiness.nowAlarmsList[aindex].AlarmLevelNub > _obj.alarmLevel) {
                                modelBussiness.nowAlarmsList[aindex].AlarmLevelNub = _obj.alarmLevel;
                                modelBussiness.nowAlarmsList[aindex].AlarmLevel = ale;
                            }
                        }
                        modelBussiness.nowAlarmsList[aindex].children.push({
                            alarmFrom: "self",
                            EquipName: info.modelId + "_Server_" + _obj.devId,
                            Alarms: [_obj],
                            AlarmLevelNub: _obj.alarmLevel,
                            AlarmLevel: ale,
                        });
                    }
                }
            }
        }
    );
    if (modelBussiness.flashAlarm) {
        modelBussiness.startAlarm();
    } else {
        modelBussiness.closeAlarm();
    }
}


ModelBussiness.prototype.nowAlarmsList = [];
//=======================================================设备告警=======================================================
ModelBussiness.prototype.startAlarm = function (rs) {
    modelBussiness.closeAlarm();
    if (modelBussiness.nowAlarmsList.length > 0) {
        modelBussiness.alarmState = "start";
        $.each(modelBussiness.nowAlarmsList, function (_index, _obj) {
            if (modelBussiness.currentState == 0) {
                WT3DObj.commonFunc.flashObjsByName([_obj.EquipName], _obj.EquipName + "_flash1", webapi.getAlarmColor(_obj.AlarmLevel), 3, 200, 0);
            } else if (modelBussiness.currentState == 1) {
                if (_obj.children && _obj.children.length >= 0) {
                    var cname = [];
                    $.each(_obj.children, function (_cindex, _cobj) {
                        WT3DObj.commonFunc.flashObjsByName([_cobj.EquipName], _cobj.EquipName + "_flash1", webapi.getAlarmColor(_cobj.AlarmLevel), 3, 200, 0);
                    })

                }
            }
        });
        modelBussiness.setAlarmIntervalIndex = setInterval(function () {
            if (modelBussiness.alarmState == "close") {
                modelBussiness.closeAlarm();
                return;
            }
            $.each(modelBussiness.nowAlarmsList, function (_index, _obj) {
                if (modelBussiness.currentState == 0) {
                    WT3DObj.commonFunc.flashObjsByName([_obj.EquipName], _obj.EquipName + "_flash1", webapi.getAlarmColor(_obj.AlarmLevel), 3, 200, 0);
                } else if (modelBussiness.currentState == 1) {
                    if (_obj.children && _obj.children.length >= 0) {
                        var cname = [];
                        $.each(_obj.children, function (_cindex, _cobj) {
                            WT3DObj.commonFunc.flashObjsByName([_cobj.EquipName], _cobj.EquipName + "_flash1", webapi.getAlarmColor(_cobj.AlarmLevel), 3, 200, 0);
                        })

                    }
                }
            });
        }, 2000);
    }
}
ModelBussiness.prototype.closeAlarm = function () {
    var modelBussiness = this;
    modelBussiness.alarmState = "close";
    if (modelBussiness.setAlarmIntervalIndex) {
        clearInterval(modelBussiness.setAlarmIntervalIndex);
    }
    setTimeout(function () {
        clearnAlarmobjColor();
    }, 100);
    setTimeout(function () {
        clearnAlarmobjColor();
    }, 1000);
    setTimeout(function () {
        clearnAlarmobjColor();
    }, 2000);
    function clearnAlarmobjColor() {
        if (modelBussiness.nowAlarmsList.length > 0) {
            $.each(modelBussiness.nowAlarmsList, function (_index, _obj) {
                if (modelBussiness.currentState == 0) {
                    WT3DObj.commonFunc.ClearnSkinColorByname(_obj.EquipName);
                } else if (modelBussiness.currentState == 1) {
                    if (_obj.children && _obj.children.length >= 0) {
                        $.each(_obj.children, function (_cindex, _cobj) {
                            WT3DObj.commonFunc.ClearnSkinColorByname(_cobj.EquipName);
                        });
                    }
                }
            });
        }
    }
}
//根据模型获取告警列表
ModelBussiness.prototype.getAlarmsByModelID = function (modelID) {
    var alarmsByModel = {};
    console.log('modelBussiness.nowAlarmsList',modelBussiness);
    $.each(modelBussiness.nowAlarmsList, function (_index, _obj) {
        if (alarmsByModel[_obj.EquipName]) {
            if (_obj.alarmFrom == "self") {
                alarmsByModel[_obj.EquipName].push(_obj);
            }
        } else {
            if (_obj.alarmFrom == "self") {
                alarmsByModel[_obj.EquipName] = [_obj]
            } else {
                alarmsByModel[_obj.EquipName] = []
            }
        }
        if (_obj.children && _obj.children.length > 0) {
            $.each(_obj.children, function (_cindex, _cobj) {
                alarmsByModel[_obj.EquipName].push(_cobj);
                if (alarmsByModel[_cobj.EquipName]) {
                    alarmsByModel[_cobj.EquipName].push(_cobj);
                } else {
                    alarmsByModel[_cobj.EquipName] = [_cobj]
                }
            });
        }
    });
    console.log('alarmsByModel',alarmsByModel);
    return alarmsByModel[modelID]
}
//隐藏所有
ModelBussiness.prototype.needHideobjs = [];
ModelBussiness.prototype.hideAll = function (exceptName, sucFunc) {
    var _this = this;
    if (_this.needHideobjs.length <= 0) {
        $.each(WT3DObj.objects, function (_index, _obj) {
            if (_obj.name.indexOf(modelBussiness.roomName + "_cab_") < 0 || _obj.name.indexOf("_sGroup") > 0) {
                if (_obj.name != (exceptName) && _obj.name.indexOf("OBJCREN") < 0) {
                    _this.needHideobjs.push(_obj);
                }
            }
        });
    }
    WT3DObj.commonFunc.changeObjsOpacity(_this.needHideobjs, 1, 0.01, 1000, function () {
        $.each(_this.needHideobjs, function (_index, _obj) {
            _obj.visible = false;
            if (_obj.children && _obj.children.length > 0) {
                $.each(_obj.children, function (_cindex, _cobj) {
                    _cobj.visible = false;
                });
            }
        });
        WT3DObj.commonFunc.changeObjsOpacity(_this.needHideobjs, 0.01, 1, 1, function () {
            if (sucFunc) {
                sucFunc();
            }
        });
    });

}
ModelBussiness.prototype.needHideCabinets = [];
ModelBussiness.prototype.hideAllCabinet = function (exceptName, sucFunc) {
    var _this = this;
    if (_this.needHideCabinets.length <= 0) {
        $.each(WT3DObj.objects, function (_index, _obj) {
            if (_obj.name.indexOf("dev_") >= 0 || _obj.name.indexOf("rack_") >= 0) {
                _this.needHideCabinets.push(_obj);
            }
        });
    }
    WT3DObj.commonFunc.changeObjsOpacity(_this.needHideCabinets, 1, 0.01, 1000, function () {
        layer.closeAll();
        if (modelBussiness.lastMouseInCurrentObj) {
            modelBussiness.commonFunc.removeLightBorder(modelBussiness.lastMouseInCurrentObj.name);
        }
        $.each(_this.needHideCabinets, function (_index, _obj) {
            _obj.visible = false;
        });
        WT3DObj.commonFunc.changeObjsOpacity(_this.needHideCabinets, 0.01, 1, 1, function () {
            if (sucFunc) {
                sucFunc();
            }
        });
    });

}

//复位按钮
ModelBussiness.prototype.backBtn = function () {
    var _this = modelBussiness;
    layer.closeAll();
    $("#backBtn").fadeOut();
    $("#toolbar").fadeIn();
    $("#canNetDetail").remove();

    this.currentState = 0;
    modelBussiness.closeHumidity();
    modelBussiness.closeCabDoor(true);
    modelBussiness.backShowSingleServer();
    _this.temptureSpaceState = 0;
    _this.hideAllTemptureMapObjs();
    _this.hideEnergyRate();
    _this.hideSpaceRate();
    _this.hideUsageSpaceRate();
    _this.hideBearing();
    if (_this.needHideCabinets.length > 0) {
        WT3DObj.commonFunc.changeCameraPosition(roomConfig.cameraPostion,
            roomConfig.cameraTarget, 1000, function () {
                $.each(_this.needHideCabinets, function (_index, _obj) {
                    if (_obj.name.indexOf("_rate_") < 0 && _obj.name.indexOf("_energy_") < 0 && _obj.name.indexOf("_yearCube_") < 0) {
                        _obj.visible = true;
                    }
                });
            });
    }
    if (_this.needHideobjs.length > 0) {
        WT3DObj.commonFunc.changeCameraPosition(roomConfig.cameraPostion,
            roomConfig.cameraTarget, 1500, function () {
                $.each(_this.needHideobjs, function (_index, _obj) {
                    if (_obj.name.indexOf("TCL_line_") < 0 && _obj.name.indexOf("_wind") < 0) {
                        _obj.visible = true;
                        if (_obj.children && _obj.children.length > 0) {
                            $.each(_obj.children, function (_cindex, _cobj) {
                                _cobj.visible = true;
                            });
                        }
                    }
                });
                _this.hideDevs();
                WT3DObj.commonFunc.changeObjsOpacity(_this.needHideobjs, 0.01, 1, 1000, function () {
                    _this.hideUsageSpaceRate();
                    _this.hideBearing();
                    _this.hideEnergyRate();
                    _this.hideSpaceRate();
                });
            });
    } else {
        WT3DObj.commonFunc.changeCameraPosition(roomConfig.cameraPostion,
            roomConfig.cameraTarget, 1000, function () { });
    }
}
ModelBussiness.prototype.backBtnClick = function () {
    modelBussiness.backBtn();
}


ModelBussiness.prototype.borderObjs = [];
//commonFunc
ModelBussiness.prototype.commonFunc = {
    //创建利用率盒子
    createRateCube: function (name, size, position, rotation, rate, animation) {
        var style = {
            borderColor: 0xffffff,
            innerColor: 0x6495ed,
            innerOprity: 1,
            outColor: 0xffffff,
            outOprity: 0.1
        };
        if (rate > 0.90) {
            style.innerColor = 0xff0000;
        } else if (rate > 0.70) {
            style.innerColor = 0xffa500;
        } else if (rate > 0.50) {
            style.innerColor = 0xffff00;
        }
        if (modelBussiness.rateSpaceCubeNames.indexOf(name) < 0) {
            modelBussiness.rateSpaceCubeNames.push(name);
            /*
              style:{
              borderColor:
              innerColor:
              innerOprity:
              outColor:
              outOprity:
              }
              */
            var rateCubes = [{
                "show": true,
                "uuid": "",
                "name": name + "_rate_outCube", "objType": "cube2",
                "length": size.x,
                "width": size.z,
                "height": size.y,
                "x": position.x, "y": position.y, "z": position.z,
                "style": { "skinColor": style.outColor, "skin": { "skin_up": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_down": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_fore": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_behind": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_left": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_right": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity } } },
                "showSortNub": 991,
                "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                "rotation": [{ "direction": "x", "degree": rotation.x }, { "direction": "y", "degree": rotation.y }, { "direction": "z", "degree": rotation.z }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
            }, {
                "show": true,
                "uuid": "",
                "name": name + "_rate_innerCube",
                "objType": "cube2",
                "length": size.x - 4,
                "width": size.z - 4,
                "height": size.y,
                "x": position.x,
                "y": position.y - (size.y / 2 - size.y * rate / 2),
                "z": position.z,
                "style": { "skinColor": style.innerColor, "skin": { "skin_up": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_down": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_fore": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_behind": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_left": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_right": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" } } },
                "showSortNub": 990,
                "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                "rotation": [{ "direction": "x", "degree": rotation.x },
                { "direction": "y", "degree": rotation.y },
                { "direction": "z", "degree": rotation.z }],
                "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
            }
            ];
            WT3DObj.commonFunc.loadModelsByJsons(rateCubes, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true, function () {
                var outcubeobj = WT3DObj.commonFunc.findObject(name + "_rate_outCube");
                var innercubeobj = WT3DObj.commonFunc.findObject(name + "_rate_innerCube");
                var edges = new THREE.EdgesHelper(outcubeobj, style.borderColor);
                modelBussiness.rateSpaceCubes.push(outcubeobj);
                modelBussiness.rateSpaceCubes.push(innercubeobj);
                modelBussiness.rateSpaceCubes.push(edges);
                edges.position.x = outcubeobj.position.x;
                edges.position.y = outcubeobj.position.y;
                edges.position.z = outcubeobj.position.z;
                edges.rotation.x = outcubeobj.rotation.x;
                edges.rotation.y = outcubeobj.rotation.y;
                edges.rotation.z = outcubeobj.rotation.z;
                edges.name = name + "_rate_outCubeBorder"
                WT3DObj.addObject(edges);
                if (animation) {
                    var innercubeobj = WT3DObj.commonFunc.findObject(name + "_rate_innerCube");
                    var outCube = WT3DObj.commonFunc.findObject(name + "_rate_outCube");
                    var outCubeBorder = WT3DObj.commonFunc.findObject(name + "_rate_outCubeBorder");
                    outCubeBorder.visible = true;
                    outCube.visible = true;
                    innercubeobj.visible = true;

                    if (innercubeobj.oldPositionY || innercubeobj.oldPositionY == 0) {
                        innercubeobj.position.y = innercubeobj.oldPositionY
                    }

                    if (outCubeBorder.oldPositionY || outCubeBorder.oldPositionY == 0) {
                        outCubeBorder.position.y = outCubeBorder.oldPositionY
                    }

                    if (outCube.oldPositionY || outCube.oldPositionY == 0) {
                        outCube.position.y = outCube.oldPositionY
                    }

                    innercubeobj.scale.y = 0.01;
                    innercubeobj.position.y = position.y - size.y / 2;
                    WT3DObj.commonFunc.setSkinColorByObj(innercubeobj, style.innerColor);
                    innercubeobj.visible = true;
                    new TWEEN.Tween(innercubeobj.scale).to({ y: 1 * rate }, animation.timelong)
                        .onUpdate(function () {
                            innercubeobj.position.y = position.y - (size.y / 2 - innercubeobj.geometry.parameters.height * innercubeobj.scale.y / 2);
                            innercubeobj.matrixAutoUpdate = true;
                        }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                        }).start();
                }
            });

        } else if (animation) {
            {
                var innercubeobj = WT3DObj.commonFunc.findObject(name + "_rate_innerCube");
                var outCube = WT3DObj.commonFunc.findObject(name + "_rate_outCube");
                var outCubeBorder = WT3DObj.commonFunc.findObject(name + "_rate_outCubeBorder");
                outCubeBorder.visible = true;
                outCube.visible = true;
                innercubeobj.visible = true;

                if (innercubeobj.oldPositionY || innercubeobj.oldPositionY == 0) {
                    innercubeobj.position.y = innercubeobj.oldPositionY
                }

                if (outCubeBorder.oldPositionY || outCubeBorder.oldPositionY == 0) {
                    outCubeBorder.position.y = outCubeBorder.oldPositionY
                }

                if (outCube.oldPositionY || outCube.oldPositionY == 0) {
                    outCube.position.y = outCube.oldPositionY
                }

                innercubeobj.scale.y = 0.01;
                innercubeobj.position.y = position.y - size.y / 2;
                WT3DObj.commonFunc.setSkinColorByObj(innercubeobj, style.innerColor);
                innercubeobj.visible = true;
                new TWEEN.Tween(innercubeobj.scale).to({ y: 1 * rate }, animation.timelong)
                    .onUpdate(function () {
                        innercubeobj.position.y = position.y - (size.y / 2 - innercubeobj.geometry.parameters.height * innercubeobj.scale.y / 2);
                        innercubeobj.matrixAutoUpdate = true;
                    }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                    }).start();
            }
        }

    },
    //创建功率盒子
    createEnergyCube: function (name, size, position, rotation, rate, animation) {
        var style = {
            borderColor: 0xffffff,
            innerColor: 0xffaa00,
            innerOprity: 0.9,
            outColor: 0x00ff00,
            outOprity: 0.05
        };
        if (modelBussiness.energySpaceCubeNames.indexOf(name) < 0) {
            modelBussiness.energySpaceCubeNames.push(name);
            /*
              style:{
              borderColor:
              innerColor:
              innerOprity:
              outColor:
              outOprity:
              }
              */
            var rateCubes = [{
                "show": true,
                "uuid": "",
                "name": name + "_energy_outCube", "objType": "cube2",
                "length": size.x,
                "width": size.z,
                "height": size.y,
                "x": position.x, "y": position.y, "z": position.z,
                "style": { "skinColor": style.outColor, "skin": { "skin_up": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_down": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_fore": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_behind": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_left": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity }, "skin_right": { "skinColor": style.outColor, "side": 1, "opacity": style.outOprity } } },
                "showSortNub": 991,
                "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                "rotation": [{ "direction": "x", "degree": rotation.x }, { "direction": "y", "degree": rotation.y }, { "direction": "z", "degree": rotation.z }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
            }, {
                "show": true,
                "uuid": "",
                "name": name + "_energy_innerCube",
                "objType": "cube2",
                "length": size.x - 4,
                "width": size.z - 4,
                "height": size.y,
                "x": position.x,
                "y": position.y - (size.y / 2 - size.y * rate / 2),
                "z": position.z,
                "style": { "skinColor": style.innerColor, "skin": { "skin_up": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_down": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_fore": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_behind": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_left": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_right": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" } } },
                "showSortNub": 990,
                "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                "rotation": [{ "direction": "x", "degree": rotation.x },
                { "direction": "y", "degree": rotation.y },
                { "direction": "z", "degree": rotation.z }],
                "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
            }
            ];
            WT3DObj.commonFunc.loadModelsByJsons(rateCubes, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true, function () {
                var outcubeobj = WT3DObj.commonFunc.findObject(name + "_energy_outCube");
                var innercubeobj = WT3DObj.commonFunc.findObject(name + "_energy_innerCube");
                var edges = new THREE.EdgesHelper(outcubeobj, style.borderColor);
                modelBussiness.energySpaceCubes.push(outcubeobj);
                modelBussiness.energySpaceCubes.push(innercubeobj);
                modelBussiness.energySpaceCubes.push(edges);
                edges.position.x = outcubeobj.position.x;
                edges.position.y = outcubeobj.position.y;
                edges.position.z = outcubeobj.position.z;
                edges.rotation.x = outcubeobj.rotation.x;
                edges.rotation.y = outcubeobj.rotation.y;
                edges.rotation.z = outcubeobj.rotation.z;
                edges.name = name + "_energy_outCubeBorder"
                WT3DObj.addObject(edges);
                if (animation) {
                    var innercubeobj = WT3DObj.commonFunc.findObject(name + "_energy_innerCube");
                    var outCube = WT3DObj.commonFunc.findObject(name + "_energy_outCube");
                    var outCubeBorder = WT3DObj.commonFunc.findObject(name + "_energy_outCubeBorder");
                    outCubeBorder.visible = true;
                    outCube.visible = true;
                    innercubeobj.visible = true;

                    if (innercubeobj.oldPositionY || innercubeobj.oldPositionY == 0) {
                        innercubeobj.position.y = innercubeobj.oldPositionY
                    }

                    if (outCubeBorder.oldPositionY || outCubeBorder.oldPositionY == 0) {
                        outCubeBorder.position.y = outCubeBorder.oldPositionY
                    }

                    if (outCube.oldPositionY || outCube.oldPositionY == 0) {
                        outCube.position.y = outCube.oldPositionY
                    }

                    innercubeobj.scale.y = 0.01;
                    innercubeobj.position.y = position.y - size.y / 2;
                    WT3DObj.commonFunc.setSkinColorByObj(innercubeobj, style.innerColor);
                    innercubeobj.visible = true;
                    new TWEEN.Tween(innercubeobj.scale).to({ y: 1 * rate }, animation.timelong)
                        .onUpdate(function () {
                            innercubeobj.position.y = position.y - (size.y / 2 - innercubeobj.geometry.parameters.height * innercubeobj.scale.y / 2);
                            innercubeobj.matrixAutoUpdate = true;
                        }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                        }).start();
                }
            });

        }

        else if (animation) {
            var innercubeobj = WT3DObj.commonFunc.findObject(name + "_energy_innerCube");
            var outCube = WT3DObj.commonFunc.findObject(name + "_energy_outCube");
            var outCubeBorder = WT3DObj.commonFunc.findObject(name + "_energy_outCubeBorder");
            outCubeBorder.visible = true;
            outCube.visible = true;
            innercubeobj.visible = true;

            if (innercubeobj.oldPositionY || innercubeobj.oldPositionY == 0) {
                innercubeobj.position.y = innercubeobj.oldPositionY
            }

            if (outCubeBorder.oldPositionY || outCubeBorder.oldPositionY == 0) {
                outCubeBorder.position.y = outCubeBorder.oldPositionY
            }

            if (outCube.oldPositionY || outCube.oldPositionY == 0) {
                outCube.position.y = outCube.oldPositionY
            }

            innercubeobj.scale.y = 0.01;
            innercubeobj.position.y = position.y - size.y / 2;
            WT3DObj.commonFunc.setSkinColorByObj(innercubeobj, style.innerColor);
            innercubeobj.visible = true;
            new TWEEN.Tween(innercubeobj.scale).to({ y: 1 * rate }, animation.timelong)
                .onUpdate(function () {
                    innercubeobj.position.y = position.y - (size.y / 2 - innercubeobj.geometry.parameters.height * innercubeobj.scale.y / 2);
                    innercubeobj.matrixAutoUpdate = true;
                }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                }).start();
        }
    },
    //创建u位盒子
    createUseageCube: function (name, size, position, rotation, temptureValue, style, animation, i) {

        setTimeout(function () {
            if (modelBussiness.agesSpaceCubeNames.indexOf(name) < 0) {
                modelBussiness.agesSpaceCubeNames.push(name);
                /*
                temptureValue:[{
                    value:26,
                    max:10,
                    min:1
                }]
                  style:{
                  borderColor:
                  outColor:
                  outOprity:
                  }
                  */
                var rateCubes = [{
                    "show": true,
                    "uuid": "",
                    "name": name + "_yearCube_outCube", "objType": "cube2",
                    "length": size.x,
                    "width": size.z,
                    "height": size.y,
                    "x": position.x, "y": position.y, "z": position.z,
                    "style": { "skinColor": style.outColor, "skin": { "skin_up": { "skinColor": style.outColor, "side": 0, "opacity": style.outOprity }, "skin_down": { "skinColor": style.outColor, "side": 0, "opacity": style.outOprity }, "skin_fore": { "skinColor": style.outColor, "side": 0, "opacity": style.outOprity }, "skin_behind": { "skinColor": style.outColor, "side": 0, "opacity": style.outOprity }, "skin_left": { "skinColor": style.outColor, "side": 0, "opacity": style.outOprity }, "skin_right": { "skinColor": style.outColor, "side": 0, "opacity": style.outOprity } } },
                    "showSortNub": 10001,
                    "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                    "rotation": [{ "direction": "x", "degree": rotation.x }, { "direction": "y", "degree": rotation.y }, { "direction": "z", "degree": rotation.z }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
                }];
                var temptureCubeNames = [];
                for (var i = 0; i < temptureValue.length; i++) {
                    var tempColor = 0x00ccff;
                    if (temptureValue[i].value > 12) {
                        tempColor = 0x00dda1;
                    } else if (temptureValue[i].value > 6) {
                        tempColor = 0x00ccff;
                    }
                    var tempInnerOprity = 0.6;
                    rateCubes.push({
                        "show": true,
                        "uuid": "",
                        "name": name + "_yearCube_innerCube_" + i,
                        "objType": "cube2",
                        "length": size.x - 14,
                        "width": size.z - 8,
                        "height": (temptureValue[i].max - temptureValue[i].min + 1) * 21 - 4,
                        "x": position.x + 20,
                        "y": position.y - size.y / 2 + (temptureValue[i].min - 1) * 21 + (temptureValue[i].max - temptureValue[i].min + 1) * 10.5,
                        "z": position.z,
                        "style": { "skinColor": tempColor, "skin": { "skin_up": { "skinColor": tempColor, "side": 1 }, "skin_down": { "skinColor": tempColor, "side": 1, "opacity": tempInnerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_fore": { "skinColor": tempColor, "side": 1, "opacity": tempInnerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_behind": { "skinColor": tempColor, "side": 1, "opacity": tempInnerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_left": { "skinColor": tempColor, "side": 1, "opacity": tempInnerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_right": { "skinColor": tempColor, "side": 1, "opacity": tempInnerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" } } },
                        "showSortNub": 9999,
                        "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                        "rotation": [{ "direction": "x", "degree": rotation.x },
                        { "direction": "y", "degree": rotation.y },
                        { "direction": "z", "degree": rotation.z }],
                        "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
                    });
                    temptureCubeNames.push(name + "_yearCube_innerCube_" + i);
                }
                WT3DObj.commonFunc.loadModelsByJsons(rateCubes, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true, function () {
                    var outcubeobj = WT3DObj.commonFunc.findObject(name + "_yearCube_outCube");
                    var edges = new THREE.EdgesHelper(outcubeobj, style.borderColor);
                    modelBussiness.agesSpaceCubes.push(outcubeobj);
                    var innercubes = WT3DObj.commonFunc.findObjectsByNames(temptureCubeNames);
                    $.each(innercubes, function (_index, _cobj) {
                        modelBussiness.agesSpaceCubes.push(_cobj);
                    });
                    modelBussiness.agesSpaceCubes.push(edges);
                    edges.material.opacity = 0.5;
                    edges.material.transparent = true;
                    edges.renderOrder = 20000;
                    edges.position.x = outcubeobj.position.x;
                    edges.position.y = outcubeobj.position.y;
                    edges.position.z = outcubeobj.position.z;
                    edges.rotation.x = outcubeobj.rotation.x;
                    edges.rotation.y = outcubeobj.rotation.y;
                    edges.rotation.z = outcubeobj.rotation.z;
                    edges.name = name + "_yearCube_outCubeBorder"
                    WT3DObj.addObject(edges);
                });

            } else {
                if (modelBussiness.agesSpaceCubes && modelBussiness.agesSpaceCubes.length > 0) {
                    $.each(modelBussiness.agesSpaceCubes, function (_index, _obj) {
                        _obj.visible = true;
                    });
                }
            }
        }, 5 * i);

    },
    //创建承重盒子
    createBearing: function (name, size, position, rotation, bearing, style, animation) {
        if (modelBussiness.BearingCubeNames.indexOf(name) < 0) {

            var bearingCubes = [
                {
                    "show": true,
                    "uuid": "",
                    "name": name + "_bearing_innerCube",
                    "objType": "cube2",
                    "length": size.x - 4,
                    "width": size.z - 4,
                    "height": size.y,
                    "x": position.x,
                    "y": position.y - (size.y / 2 - size.y * bearing / 2),
                    "z": position.z,
                    "style": { "skinColor": style.innerColor, "skin": { "skin_up": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_down": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_fore": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_behind": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_left": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" }, "skin_right": { "skinColor": style.innerColor, "side": 1, "opacity": style.innerOprity, "imgurl": "../img/3dImg/outside_lightmap.jpg" } } },
                    "showSortNub": 999,
                    "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null,
                    "rotation": [{ "direction": "x", "degree": rotation.x },
                    { "direction": "y", "degree": rotation.y },
                    { "direction": "z", "degree": rotation.z }],
                    "thick": null, "scale": { "x": 1, "y": bearing, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
                }
            ];
            WT3DObj.commonFunc.loadModelsByJsons(bearingCubes, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true, function () {
                var innercubeobj = WT3DObj.commonFunc.findObject(name + "_bearing_innerCube");
                modelBussiness.BearingCubeNames.push(name);
                modelBussiness.BearingCubes.push(innercubeobj);

                if (animation) {
                    var innercubeobj = WT3DObj.commonFunc.findObject(name + "_bearing_innerCube");
                    innercubeobj.visible = true;
                    innercubeobj.scale.y = 0.01;
                    innercubeobj.position.y = position.y - size.y / 2;
                    innercubeobj.visible = true;
                    new TWEEN.Tween(innercubeobj.scale).to({ y: bearing }, animation.timelong)
                        .onUpdate(function () {
                            innercubeobj.position.y = position.y - (size.y / 2 - innercubeobj.geometry.parameters.height * innercubeobj.scale.y / 2);
                            innercubeobj.matrixAutoUpdate = true;
                        }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                        }).start();
                }
            });



        }
        else if (animation) {

            var bearingcubeindex = modelBussiness.BearingCubeNames.indexOf(name);
            var innercubeobj = modelBussiness.BearingCubes[bearingcubeindex];
            if (!innercubeobj) {
                innercubeobj = WT3DObj.commonFunc.findObject(name + "_bearing_innerCube");
            }

            innercubeobj.visible = true;

            innercubeobj.scale.y = 0.01;
            innercubeobj.position.y = position.y - size.y / 2;

            WT3DObj.commonFunc.setSkinColorByObj(innercubeobj, style.innerColor);
            innercubeobj.visible = true;
            new TWEEN.Tween(innercubeobj.scale).to({ y: bearing }, animation.timelong)
                .onUpdate(function () {
                    innercubeobj.position.y = position.y - (size.y / 2 - innercubeobj.geometry.parameters.height * innercubeobj.scale.y / 2);
                    innercubeobj.matrixAutoUpdate = true;
                }).easing(TWEEN.Easing.Elastic.Out).onComplete(function () {
                }).start();
        }
    },
    //打开机柜单门
    opcabinetMaindoor: function (_obj, _cmd, _func) {
        var doorstate = "close";
        var tempobj = null;
        if (typeof (_obj.doorState) != 'undefined' && _obj.doorState != null) {
            doorstate = _obj.doorState;
            tempobj = _obj.parent;
        } else {
            _obj.oldPosition = {
                x: _obj.parent.position.x, y: _obj.parent.position.y, z: _obj.parent.position.z
            }
            _obj.doorstate = "close";
            var _objparent = _obj.parent;
            tempobj = new THREE.Object3D();
            tempobj.name = _obj.name + "_mainDoor";
            tempobj.position.set(_obj.position.x, _obj.position.y, _obj.position.z - _obj.geometry.parameters.depth / 2);
            _obj.position.set(0, 0, _obj.geometry.parameters.depth / 2);
            _obj.matrixAutoUpdate = true;
            tempobj.add(_obj);
            _objparent.add(tempobj);
        }
        if (typeof (_cmd) == 'undefined' || _cmd == null || _cmd == "") {
            _obj.doorState = (doorstate == "close" ? "open" : "close");
        } else {
            if (_cmd == _obj.doorState) {
                if (_func != null) {
                    _func();
                }
                return;
            } else {
                _obj.doorState = _cmd;
            }
        }
        new TWEEN.Tween(tempobj.rotation).to({
            y: (_obj.doorState == "open" ? 0.5 * Math.PI : 0)
        }, 1000).onComplete(function () {
            if (_func != null) {
                _func();
            }
        }).start();
    },
    //打开机柜双门-左
    opcabinetBackLeftdoor: function (_obj, _cmd, _func) {
        var doorstate = "close";
        var tempobj = null;
        if (typeof (_obj.doorState) != 'undefined' && _obj.doorState != null) {
            doorstate = _obj.doorState;
            tempobj = _obj.parent;
        } else {
            _obj.oldPosition = {
                x: _obj.parent.position.x, y: _obj.parent.position.y, z: _obj.parent.position.z
            }
            _obj.doorstate = "close";
            var _objparent = _obj.parent;
            tempobj = new THREE.Object3D();
            tempobj.name = _obj.name + "_leftDoor";
            tempobj.position.set(_obj.position.x, _obj.position.y, _obj.position.z - _obj.geometry.parameters.depth / 2);
            _obj.position.set(0, 0, _obj.geometry.parameters.depth / 2);
            _obj.matrixAutoUpdate = true;
            tempobj.add(_obj);
            _objparent.add(tempobj);
        }
        if (typeof (_cmd) == 'undefined' || _cmd == null || _cmd == "") {
            _obj.doorState = (doorstate == "close" ? "open" : "close");
        } else {
            if (_cmd == _obj.doorState) {
                if (_func != null) {
                    _func();
                }
                return;
            } else {
                _obj.doorState = _cmd;
            }
        }
        new TWEEN.Tween(tempobj.rotation).to({
            y: (_obj.doorState == "open" ? -0.5 * Math.PI : 0)
        }, 1000).onComplete(function () {
            if (_func != null) {
                _func();
            }
        }).start();
    },
    //打开机柜双门-右
    opcabinetBackRightdoor: function (_obj, _cmd, _func) {
        var doorstate = "close";
        var tempobj = null;
        if (typeof (_obj.doorState) != 'undefined' && _obj.doorState != null) {
            doorstate = _obj.doorState;
            tempobj = _obj.parent;
        } else {
            _obj.oldPosition = {
                x: _obj.parent.position.x, y: _obj.parent.position.y, z: _obj.parent.position.z
            }
            _obj.doorstate = "close";
            var _objparent = _obj.parent;
            tempobj = new THREE.Object3D();
            tempobj.name = _obj.name + "_rightDoor";
            tempobj.position.set(_obj.position.x, _obj.position.y, _obj.position.z + _obj.geometry.parameters.depth / 2);
            _obj.position.set(0, 0, -_obj.geometry.parameters.depth / 2);
            _obj.matrixAutoUpdate = true;
            tempobj.add(_obj);
            _objparent.add(tempobj);
        }
        if (typeof (_cmd) == 'undefined' || _cmd == null || _cmd == "") {
            _obj.doorState = (doorstate == "close" ? "open" : "close");
        } else {
            if (_cmd == _obj.doorState) {
                if (_func != null) {
                    _func();
                }
                return;
            } else {
                _obj.doorState = _cmd;
            }
        }
        new TWEEN.Tween(tempobj.rotation).to({
            y: (_obj.doorState == "open" ? 0.5 * Math.PI : 0)
        }, 1000).onComplete(function () {
            if (_func != null) {
                _func();
            }
        }).start();
    },
    addLightBoder: function (outcubeobj, color, op, group, size) {
        if (outcubeobj.name.indexOf("LightCubeBorder") > 0) {
            return;
        }
        if (WT3DObj.commonFunc.findObject(outcubeobj.name + "_LightCubeBorder")) {
            return;
        }
        if (group) {

        } else {
            if (modelBussiness.lightBorderModel) {
                modelBussiness.commonFunc.removeLightBorder(modelBussiness.lightBorderModel);
            }
        }

        var borderLightJson = {
            "show": true, "uuid": "", "name": outcubeobj.name + "_LightCubeBorderLight", "objType": "cube2", "length": size ? size.x : 204, "width": size ? size.z : 154, "height": size ? size.y : 386, "x": outcubeobj.position.x, "y": outcubeobj.position.y, "z": outcubeobj.position.z,
            "style": { "skinColor": color, "skin": { "skin_up": { "skinColor": color, "side": 1, "opacity": op, "imgurl": "../img/3dImg/bg203.png" }, "skin_down": { "skinColor": color, "side": 1, "opacity": op, "imgurl": "../img/3dImg/bg203.png" }, "skin_fore": { "skinColor": color, "side": 1, "opacity": op, "imgurl": "../img/3dImg/bg203.png" }, "skin_behind": { "skinColor": color, "side": 1, "opacity": op, "imgurl": "../img/3dImg/bg203.png" }, "skin_left": { "skinColor": color, "side": 1, "opacity": op, "imgurl": "../img/3dImg/bg203.png" }, "skin_right": { "skinColor": color, "side": 1, "opacity": op, "imgurl": "../img/3dImg/bg203.png" } } }, "showSortNub": 700000, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": outcubeobj.rotation.y }, { "direction": "z", "degree": 0 }], "thick": null, "scale": { "x": 1, "y": 1, "z": 1 }, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null
        };
        WT3DObj.InitAddObject(borderLightJson);
        modelBussiness.borderObjs.push(outcubeobj.name + "_LightCubeBorderLight");

    },
    removeLightBorder: function (outcubeobjName) {
        WT3DObj.destoryObj(outcubeobjName.replace("_LightCubeBorderLight", "").replace("_LightCubeBorder", "") + "_LightCubeBorderLight");
        WT3DObj.destoryObj(outcubeobjName.replace("_LightCubeBorderLight", "").replace("_LightCubeBorder", "") + "_LightCubeBorder");
        if (modelBussiness.borderObjs.length > 0) {
            $.each(modelBussiness.borderObjs, function (_index, _obj) {
                WT3DObj.destoryObj(_obj.replace("_LightCubeBorderLight", "").replace("_LightCubeBorder", "") + "_LightCubeBorderLight");
                WT3DObj.destoryObj(_obj.replace("_LightCubeBorderLight", "").replace("_LightCubeBorder", "") + "_LightCubeBorder");
            });
            modelBussiness.borderObjs = [];
        }
    },
    showMsg: function (_obj, position, closeFunc) {
        //获取位置
        var screenPostion = WT3DObj.commonFunc.transToScreenCoord(position);
        $("#MarkMessageHelper").remove();
        $("body").append("<div id='MarkMessageHelper' style='position:absolute;left:" + (screenPostion.x - 30) + "px;top:" + screenPostion.y + "px;height:2px;width:2px;z-index:1000;'></div>");
        layer.closeAll();
        var name = _obj.name.split("_energy_")[0].split("_rate_")[0].split("_yearCube_")[0];
        var info = getRelationInfoByModelId(name);

        if (showCabnetCustomEasyDetail) {
            showCabnetCustomEasyDetail(info.dataId, name, closeFunc);
        }
    },
    showDevMsg: function (_obj, position, closeFunc) {
        //获取位置
        var screenPostion = WT3DObj.commonFunc.transToScreenCoord(position);
        $("#MarkMessageHelper").remove();
        $("body").append("<div id='MarkMessageHelper' style='position:absolute;left:" + (screenPostion.x - 30) + "px;top:" + screenPostion.y + "px;height:2px;width:2px;z-index:1000;'></div>");
        layer.closeAll();
        var info = getRelationInfoByModelId(_obj.name);
        if (showDevCustomDetail && info) {
            showDevCustomDetail(info.dataId, _obj.name, closeFunc);
        }
    },
    showDevEasyMsg: function (_obj, position, closeFunc) {
        //获取位置
        var screenPostion = WT3DObj.commonFunc.transToScreenCoord(position);
        $("#MarkMessageHelper").remove();
        $("body").append("<div id='MarkMessageHelper' style='position:absolute;left:" + (screenPostion.x - 30) + "px;top:" + screenPostion.y + "px;height:2px;width:2px;z-index:1000;'></div>");
        layer.closeAll();
        var info = getRelationInfoByModelId(_obj.name);
        if (showDevCustomEasyDetail && info) {
            showDevCustomEasyDetail(info.dataId, _obj.name, closeFunc);
        }
    },
    showServerMsg: function (_obj, position, closeFunc) {
        //获取位置
        var screenPostion = WT3DObj.commonFunc.transToScreenCoord(position);
        var leftPostion = WT3DObj.commonFunc.transToScreenCoord({ x: position.x, y: position.y, z: position.z });
        $("#MarkMessageHelper").remove();
        $("body").append("<div id='MarkMessageHelper' style='position:absolute;left:" + (leftPostion.x - Math.abs(leftPostion.x - screenPostion.x) + 80) + "px;top:" + (screenPostion.y + Math.abs(leftPostion.y - screenPostion.y) - 5) + "px;z-index:1000;'></div>");
        var serverid = _obj.name.split("_Server_")[1];
        if (showServerCustomDetail) {
            showServerCustomDetail(_obj.name, serverid, closeFunc, position);
        }
    },
    showCabnetDetail: function (_obj) {
        setTimeout(function () {

            console.log('showCabnetDetail',1111111111111111111111);

            var info = getRelationInfoByModelId(_obj.name);
            if (showCabnetCustomDetail && info) {
                showCabnetCustomDetail(info.dataId, info.name);
            }
        }, 1000);
    },
    ZoomINShow: function (_obj, face) {
        var mainCamera = WT3DModel.camera;//主场景
        var objpositionx = _obj.position.x;
        var objpositiony = _obj.position.y;
        var objpositionz = _obj.position.z;
        if (typeof (_obj.parent) != 'undefined' && _obj.parent != null && typeof (_obj.parent.position) != 'undefined' && _obj.parent.position != null) {
            objpositionx += _obj.parent.position.x;
            objpositiony += _obj.parent.position.y;
            objpositionz += _obj.parent.position.z;
        }
        if (typeof (_obj.oldPosition) != 'undefined' && _obj.oldPosition != null) {
            objpositionx = _obj.oldPosition.x;
            objpositiony = _obj.oldPosition.y;
            objpositionz = _obj.oldPosition.z;
        }
        new TWEEN.Tween(WT3DModel.controls.target).to({
            x: objpositionx, y: objpositiony, z: objpositionz
        }, 600).onComplete(function () {
            var x_distance = mainCamera.position.x - objpositionx;
            var y_distance = mainCamera.position.y - objpositiony;
            var z_distance = mainCamera.position.z - objpositionz;
            var lv = 1000 / Math.sqrt(x_distance * x_distance + y_distance * y_distance + z_distance * z_distance);
            var runtweenTime = 1000;
            if (lv > 0.6) {
                runtweenTime = 400;
            } else if (lv > 0.3) {
                runtweenTime = 1000;
            } else if (lv > 0.1) {
                runtweenTime = 1200;
            } else if (lv > 0.05) {
                runtweenTime = 1600;
            } else if (lv > 0.01) {
                runtweenTime = 2000;
            } else {
                runtweenTime = 2500;
            }
            if (x_distance * x_distance + y_distance * y_distance + z_distance * z_distance > 800 * 800 && lv < 0.9999) {
                new TWEEN.Tween(mainCamera.position).to({
                    x: objpositionx + (mainCamera.position.x - objpositionx) * lv, y: objpositiony, z: objpositionz + (mainCamera.position.z - objpositionz) * lv
                }, runtweenTime).start();
            }


        }).start();
    },
    drawLine: function (name, path, color) {
        var models = [{ "show": true, "uuid": "", "name": name, "objType": "SplineCurve", "segments": 2, "points": path, "style": { "skinColor": color }, "LineStyle": "LinePieces", "position": { "x": 475.747, "y": 0, "z": 0 }, "scale": { "x": 1, "y": 1, "z": 1 }, "rotation": [{ "direction": "x", "degree": 0 }, { "direction": "y", "degree": 0 }, { "direction": "z", "degree": 0 }], "showSortNub": 7, "customType1": "", "customType2": "", "animation": null, "dbclickEvents": null, "BindDevId": null, "BindDevName": null, "devInfo": null, "BindMeteId": null, "BindMeteName": null }];
        WT3DObj.commonFunc.loadModelsByJsons(models, { x: 0, y: 0, z: 0 }, { x: 0, y: 0, z: 0 }, true);
    },
    removeLine: function (name) {
        WT3DObj.destoryObj(name);
    }
}


//绑定悬停事件
ModelBussiness.prototype.bindHoverEvent = function () {
    //悬停回调
    WT3DObj.mouseOverCallBack = this.mouseOverCallBack;
    //进入回调
    WT3DObj.mouseOverInCallBack = this.mouseOverInCallBack;
    //离开回调
    WT3DObj.mouseOverLeaveCallBack = this.mouseOverLeaveCallBack;
    //悬停触发时间长度
    WT3DObj.mouseOverTimeLong = 1000;
}
//悬停
ModelBussiness.prototype.mouseOverCallBack = function (_obj, face) {

}
ModelBussiness.prototype.mouseInCurrentObj = null;
ModelBussiness.prototype.lastMouseInCurrentObj = null;
//鼠标滑入回调
ModelBussiness.prototype.mouseOverInCallBack = function (_obj, face) {
    var _this = this;
    var color = 0xbfffea;
    console.log(_obj.name);

    modelBussiness.lastMouseInCurrentObj = _obj;
    modelBussiness.mouseInCurrentObj = _obj;
    return;
    if (_obj.name.indexOf("LightCubeBorder") > 0) {
        return;
    } else if (_obj.name.indexOf("rack_") >= 0
        && _obj.name.indexOf("_Server_") < 0
        && _obj.name.indexOf("_currentCabnet") < 0) {
        modelBussiness.mouseInCurrentObj = _obj;
        modelBussiness.commonFunc.addLightBoder(_obj, 0x00ffff, 1, null, {
            x: _obj.geometry.parameters.width + 20,
            y: _obj.geometry.parameters.height + 20,
            z: _obj.geometry.parameters.depth + 20,
        });
        modelBussiness.commonFunc.showMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 500, z: _obj.position.z }, function () {
            modelBussiness.commonFunc.removeLightBorder(modelBussiness.mouseInCurrentObj.name)
        });
    }
    else if (_obj.name.indexOf("_Server_") >= 0) {
        var _sobj = _obj;
        modelBussiness.commonFunc.removeLightBorder(modelBussiness.lastMouseInCurrentObj.name);
        modelBussiness.mouseInCurrentObj = _sobj;
        modelBussiness.commonFunc.showServerMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 1.5, z: _obj.position.z - 13 });
        if (modelBussiness.currentState == 10) {
            if (modelBussiness.currentShowServer.name == _sobj.name) {
                return;
            }
        }
        modelBussiness.commonFunc.addLightBoder(_sobj, 0x00ffff, 0.6, null, {
            x: _sobj.geometry.parameters.width + 4,
            y: _sobj.geometry.parameters.height + 4,
            z: _sobj.geometry.parameters.depth + 4,
        });
    }
    else if (_obj.name.indexOf("dev_T_") >= 0) {
        if (_obj.name.indexOf("OBJCREN") >= 0) {
            _obj = WT3DObj.commonFunc.findObject(_obj.name.split("OBJCREN")[0]);
        }
        modelBussiness.mouseInCurrentObj = _obj;
        WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x00ffff);

        modelBussiness.commonFunc.showDevEasyMsg(_obj, { x: _obj.position.x, y: _obj.position.y + 100, z: _obj.position.z },
            function () {
                WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x000000);
            });
    }
}
//鼠标滑出回调
ModelBussiness.prototype.mouseOverLeaveCallBack = function (_obj, face, nowobj) {
    var _this = this;
    var color = 0x000000;
    if (_obj) {
        if (_obj.name.indexOf("OBJCREN") >= 0) {
            _obj = WT3DObj.commonFunc.findObject(_obj.name.split("OBJCREN")[0]);
        }
        if (_obj) {
            if (_obj.name.indexOf("_LightCubeBorder") >= 0) {
                layer.closeAll();
                modelBussiness.commonFunc.removeLightBorder(_obj.name);
            } else if (_obj.name.indexOf("rack_") >= 0) {
                if (modelBussiness.currentState != 0) {
                    return;
                }
                if (nowobj && nowobj.name.indexOf(_obj.name + "_LightCubeBorder") >= 0) {
                    return;
                }
                modelBussiness.mouseInCurrentObj = null;
                modelBussiness.commonFunc.removeLightBorder(_obj.name);
            } else if (_obj.name.indexOf("sxj_") >= 0) {
                modelBussiness.hideCameraRange();
            } else if (_obj.name.indexOf("dev_T_") >= 0) {
                if (_obj.name.indexOf("OBJCREN") >= 0) {
                    _obj = WT3DObj.commonFunc.findObject(_obj.name.split("OBJCREN")[0]);
                }
                modelBussiness.mouseInCurrentObj = null;
                WT3DObj.commonFunc.setSkinColorByObj(_obj, 0x000000);
                layer.closeAll();

            }
        }
    }
}
ModelBussiness.prototype.showPostionState = false;
ModelBussiness.prototype.showPosition = function (cabid, serverid) {
    var _this = this;
    if (_this.showPostionState) {
        layer.msg("正在定位中，请稍后");
        return;
    }
    var waitTimelong = 0;
    if (modelBussiness.currentState > 0) {
        modelBussiness.backBtn();
        waitTimelong = 2000;
    }
    setTimeout(function () {

        _this.showPostionState = true;
        _this.currentState = 30;
        var info = getRelationInfoByDataId(cabid);
        var canNet = WT3DObj.commonFunc.findObject(info.name);
        if (_this.lastMouseInCurrentObj) {
            _this.mouseOverLeaveCallBack(_this.lastMouseInCurrentObj);
        }
        _this.mouseOverInCallBack(canNet);
        setTimeout(function () {
            layer.closeAll();
            _this.commonFunc.ZoomINShow(canNet);
            _this.dbClickSelect(canNet);

            setTimeout(function () {

                var currentCanNet = WT3DObj.commonFunc.findObject(info.name + "_currentCabnet");

                WT3DObj.commonFunc.changeCameraPosition({ x: currentCanNet.position.x - 800, y: currentCanNet.position.y + 300, z: currentCanNet.position.z },
                    { x: currentCanNet.position.x, y: currentCanNet.position.y, z: currentCanNet.position.z }, 1000, function () {

                        _this.openCabDoor(currentCanNet, "twodoor");

                        setTimeout(function () {
                            var serverobj = WT3DObj.commonFunc.findObject(info.name + "_Server_" + serverid);
                            if (serverobj) {
                                if (_this.lastMouseInCurrentObj) {
                                    _this.mouseOverLeaveCallBack(_this.lastMouseInCurrentObj);
                                }
                                _this.mouseOverInCallBack(serverobj);
                                setTimeout(function () {
                                    _this.dbClickSelect(serverobj);
                                    setTimeout(function () {
                                        _this.mouseOverInCallBack(serverobj);
                                        _this.showPostionState = false;
                                    }, 1000);
                                }, 1000);
                            } else {
                                layer.msg("数据有误");
                                _this.showPostionState = false;
                            }
                        }, 1000);

                    });

            }, 1500);
        }, 1000);

    }, waitTimelong);
}
var modelBussiness = new ModelBussiness();